package ui.face {

	import flash.display.Bitmap;
	import flash.display.Sprite;
	
	import globals.Global;
	
	import ui.component.Button;
	import ui.component.Label;
	import ui.panel.PanelType;
	
	import util.UIUtil;
	
	public class ScoreFace extends Sprite {
		
		public var heartBar:Bar;
		public var starBar:Bar;
		public var silverLabel:Label;
		public var goldLabel:Label;
		public var badgeLabel:Label;

		public function ScoreFace() {
			super();
			
			//bar bg
			var bitmap:Bitmap;
			bitmap = new Bitmap(Global.assetsManager.getAssetsAsBitmapData("money_bg"));
			bitmap.x = 16;
			bitmap.y = 10;
			addChild(bitmap);
			bitmap = new Bitmap(Global.assetsManager.getAssetsAsBitmapData("money_bg"));
			bitmap.x = 126;
			bitmap.y = 10;
			addChild(bitmap);
			bitmap = new Bitmap(Global.assetsManager.getAssetsAsBitmapData("money_bg"));
			bitmap.x = 236;
			bitmap.y = 10;
			addChild(bitmap);
			//bar icon
			bitmap = new Bitmap(Global.assetsManager.getAssetsAsBitmapData("silver_icon"));
			bitmap.y = 9;
			addChild(bitmap);
			bitmap = new Bitmap(Global.assetsManager.getAssetsAsBitmapData("gold_icon"));
			bitmap.x = 110;
			bitmap.y = 9;
			addChild(bitmap);
			bitmap = new Bitmap(Global.assetsManager.getAssetsAsBitmapData("badge"));
			bitmap.x = 220;
			bitmap.y = 4;
			addChild(bitmap);
			//bar label
			silverLabel = new Label(16, 0xFFFFFF, true);
			silverLabel.x = 30;
			silverLabel.y = 13;
			addChild(silverLabel);
			goldLabel = new Label(16, 0xFFFFFF, true);
			goldLabel.x = 140;
			goldLabel.y = 13;
			addChild(goldLabel);
			badgeLabel = new Label(16, 0xFFFFFF, true);
			badgeLabel.x = 250;
			badgeLabel.y = 13;
			addChild(badgeLabel);
			//heart and star bar
			heartBar = new Bar("track_red", "bar_bg_2");
			heartBar.x = 56;
			heartBar.y = 51;
			addChild(heartBar);
			starBar = new Bar("track_blue", "bar_bg_2");
			starBar.x = 178;
			starBar.y = 51;
			addChild(starBar);
			//heart and star bar label
			bitmap = new Bitmap(Global.assetsManager.getAssetsAsBitmapData("heart_icon"));
			bitmap.x = 45;
			bitmap.y = 43;
			addChild(bitmap);
			bitmap = new Bitmap(Global.assetsManager.getAssetsAsBitmapData("star_icon"));
			bitmap.x = 160;
			bitmap.y = 43;
			addChild(bitmap);
		}
		
		public function updateSilver(value:uint):void {
			silverLabel.text = value.toString();
		}
		
		public function updateBadge(value:uint):void {
			badgeLabel.text = value.toString();
		}
		
		public function updateGold(value:uint):void {
			goldLabel.text = value.toString();
		}
		
		public function updateHeart(value:uint, total:uint):void {
			heartBar.update(value, total);
		}
		
		public function updateStar(value:uint, total:uint):void {
			starBar.update(value, total);
		}
	}
}